package temp;

import java.util.Date;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hanhai.common.annotation.LoginNeedless;
import com.hanhai.zrb.mobile.result.BaseApiResult;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import com.wordnik.swagger.annotations.ApiResponse;
import com.wordnik.swagger.annotations.ApiResponses;


@LoginNeedless
@RestController
@RequestMapping("/proEmailApi")
public class GetProjectInfoEmaiApilcontroller {

	private final Logger logger = LoggerFactory.getLogger(GetProjectInfoEmaiApilcontroller.class);
	
	@Resource
	private GetProjectInfoEmailService getProjectInfoEmailService;
	
	@ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") })
	@ApiOperation(value = "索要更多项目信息",  response = ProjectEmailDto.class, notes = "添加")
	@RequestMapping("/insert")
	public BaseApiResult detail(
			@ApiParam(required = true, name = "email", value = "email")String email,
			@ApiParam(required = true, name = "projectId", value = "projectId")int projectId,
			@ApiParam(required = true, name = "projectName", value = "projectName")String projectName
			){
		BaseApiResult result = new BaseApiResult();
		ProjectEmailDto dto = new ProjectEmailDto();
		dto.setCreateTime(new Date());
		dto.setEmail(email);
		dto.setStatus(0);
		dto.setProjectId(projectId);
		dto.setProjectName(projectName);
		try {
			getProjectInfoEmailService.insert(dto);
			logger.info("添加 所要更多项目信息，项目名称："+ projectName +",项目id:"+projectId+",邮箱:"+email+"");
		}catch (Exception e) {
			logger.error("do proEmailApi getProjectInfoEmailService.insert(ProjectEmailDto dto) error" + e);
		}
		

		result.setMsg("添加成功"); 
		return result;
	}
}
